package com.example.dynamicdatasource.dataSource;

/**
 * 持有当前数据源名称的上下文
 * @author mqb
 * @date 2021/8/9 19:54
 */
public class DynamicDataSourceHolder {
    /**
     * 当前数据源名称
     */
    private static final ThreadLocal<String> DATASOURCE_ROUTING_KEY = new ThreadLocal<>();

    public static String get() {
        return DATASOURCE_ROUTING_KEY.get();
    }

    public static void set(String key) {
        DATASOURCE_ROUTING_KEY.set(key);
    }

    public static void remove() {
        DATASOURCE_ROUTING_KEY.remove();
    }
}
